package com.lonely.fx.bind;

import javafx.beans.binding.BooleanBinding;
import javafx.beans.binding.StringBinding;
import javafx.beans.binding.When;
import javafx.beans.property.SimpleIntegerProperty;

/**
 * @date: 2022-07-24 20:43
 * @author: ztkj-hzb
 * @description: 三元运算符 when的使用
 **/
public class WhenSettingMain {

    public static void main(String[] args) {


        SimpleIntegerProperty integerProperty1 = new SimpleIntegerProperty(10);
        SimpleIntegerProperty integerProperty2 = new SimpleIntegerProperty(5);

        BooleanBinding booleanBinding = integerProperty1.greaterThan(integerProperty2);

        //类比 10>5 ? "大于" : "小于等于"
        StringBinding binding = new When(booleanBinding).then("大于").otherwise("小于等于");
        System.out.println(String.format("%s %s %s", integerProperty1.get(), binding.get(), integerProperty2.get()));


    }


}
